package cn.com.jslh.boarpro.main.model;

import android.content.Context;

import com.blankj.utilcode.util.SPUtils;

import org.json.JSONException;
import org.json.JSONObject;

import cn.com.jslh.boarpro.base.BaseApplication;
import cn.com.jslh.boarpro.main.contract.RecordTemplateContract;
import cn.com.jslh.boarpro.util.WebService;

/**
 * Created by Administrator on 2017/11/28.
 */

public class RecordTemplateModelImpl implements RecordTemplateContract.Model {

    private Context context;
    public static RecordTemplateModelImpl instance;

    public static RecordTemplateModelImpl getInstance(Context context) {
        if (instance == null) {
            instance = new RecordTemplateModelImpl(context);
        }
        return instance;
    }

    private RecordTemplateModelImpl(Context context) {
        this.context = context;
    }

    @Override
    public void getDatas(WebService.NetSuccessListener netSuccessListener) {
        JSONObject dataObject = new JSONObject();
        try {
            dataObject.put("pageid", SPUtils.getInstance().getString(BaseApplication.MODULETYPE));
            dataObject.put("userid", SPUtils.getInstance().getString(BaseApplication.FUSERID));
            dataObject.put("lineid", SPUtils.getInstance().getString(BaseApplication.FLINEID));
        } catch (JSONException e) {
            e.printStackTrace();
        }
        new WebService.Builder(context, "recordLoad", "WSAddShowFacade")
                .addProperty("jsonString", dataObject.toString())
                .showDialog(false)
                .success(netSuccessListener)
                .post();
    }
}
